FROM alpine:3.16.2

LABEL maintainer="zhanglm8@chinatelecom.cn"

# 更新源到 tuna.tsinghua
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
  && apk add --update nginx

# 拷贝构建好的 app dist 到镜像内
COPY --chown=nginx:nginx ./app/main/dist/ /var/cns-frontend/app/
COPY --chown=nginx:nginx ./app/subApps/userManagement/dist/ /var/cns-frontend/app/subApps/userManagement/
COPY --chown=nginx:nginx ./app/subApps/eshield/dist/ /var/cns-frontend/app/subApps/eshield/
COPY --chown=nginx:nginx ./app/subApps/cloudAudit/dist/ /var/cns-frontend/app/subApps/cloudAudit/
COPY --chown=nginx:nginx ./app/subApps/firewall/dist/ /var/cns-frontend/app/subApps/firewall/
COPY --chown=nginx:nginx ./app/subApps/logsAudit/dist/ /var/cns-frontend/app/subApps/logsAudit/

ARG NGINX_LISTEN_PORT="8100"
ENV NGINX_LISTEN_PORT ${NGINX_LISTEN_PORT}

# 配置、启动 nginx
COPY ./cli/nginx/cns-frontend.conf /etc/nginx/http.d/cns-frontend.conf
RUN sed -i "s/listen [0-9]*/listen $NGINX_LISTEN_PORT/" /etc/nginx/http.d/cns-frontend.conf
CMD ["nginx", "-g", "daemon off;"]

EXPOSE ${NGINX_LISTEN_PORT}
